<template>
    <a-modal
            :title="tableTitle"
            :visible="visible"
            width="1200px"
            @ok="handleOk"
            :maskClosable="false"
            :confirmLoading="confirmLoading"
            @cancel="handleCancel"
    >
        <a-form-model ref="form" :model="form">
            <a-descriptions bordered   :column="2">
                <a-descriptions-item label="选择数据年份" :span="2">
                    <a-form-model-item
                            prop="year"
                            :rules="{
                                required: true,
                                message: '选择数据年份',
                                trigger: 'change',
                            }">
                        <xlDate
                                data-type="year"
                                @change="yearChange"
                                :placeholder="'选择数据年份'"
                                v-model="form.year">
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="团队名称" span="2">
                    <a-form-model-item
                            prop="teamName"
                            :rules="{
                                required: true,
                                message: '请输入团队名称',
                                trigger: 'change',
                            }">
                        <a-input
                                :maxLength="100"
                                :placeholder="'请输入团队名称'"
                                v-model="form.teamName">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="选择入驻时间" :span="2">
                    <a-form-model-item>
                        <xlDate
                                :placeholder="'选择入驻时间'"
                                v-model="form.joinDate">
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="负责人">
                    <a-form-model-item>
                        <a-input
                                :placeholder="'负责人'"
                                v-model="form.contactName">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="负责人电话">
                    <a-form-model-item>
                        <a-input
                                :placeholder="'请输入负责人电话'"
                                v-model="form.contactPhone">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否转为企业" :span="2">
                    <a-form-model-item>
                        <a-radio-group v-model="form.isComFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="行业领域">
                    <a-input
                            :placeholder="'请输入行业领域'"
                            v-model="form.industryDomain">
                    </a-input>
                </a-descriptions-item>
                <a-descriptions-item label="租用场地面积">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入租用场地面积'"
                                v-model="form.rentArea">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="员工人数">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入员工人数'"
                                v-model="form.employeeNum">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="获投融资额(万元)">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入获投融资额'"
                                v-model="form.hatchedAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上传合同" :span="2">
                    <a-form-model-item>
                        <xluploadFile
                                v-model="form.contractPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
            </a-descriptions>
        </a-form-model>
    </a-modal>
</template>

<script>
    import xlDate from '@/components/formUntil/xlDate'
    import xlImage from '@/components/formUntil/xlImage'
    import xluploadFile from '@/components/formUntil/xluploadFile'
    import {carrierEmployeePageList, carrierTeamMoreGetByParam} from "@/assets/api";
    export default {
        name: "xlForm",
        data() {
            return {
                tableTitle: '编辑',
                visible: false,
                confirmLoading: false,
                form: {
                },
                rules:{},
                mainId:null
            }
        },
        components:{
            xlDate,
            xlImage,
            xluploadFile
        },
        methods: {
            handleOk() {
                this.$refs.form.validate(valid => {
                    console.log(valid)
                    if (valid) {
                        this.confirmLoading = true
                        this.$emit('handleOk', this.form)
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            handleCancel() {
                this.visible = false
            },
            yearChange(){
                carrierTeamMoreGetByParam({
                    param:{
                        teamId:this.mainId,
                        year:this.form.year
                    }
                })
                    .then(result=>{
                        this.form = result.result
                        this.visible = true
                    })
            },
            formatForm(form) {
                delete form.createDateTime
                delete form.modifyDateTime
                delete form.modifyBy
                delete form.createBy
                //整理字段数据 ／ 赋值 清空等
                this.mainId = form.id
                carrierTeamMoreGetByParam({
                    param:{
                        teamId:this.mainId,
                        year:form.year
                    }
                })
                    .then(result=>{
                        this.form = result.result
                        this.visible = true
                    })

            }
        }
    }
</script>

<style scoped lang="less">
    /deep/ .ant-form-item {
        margin: 0;
    }

    /deep/.ant-input-number{
        width: 100%;
    }
    .xl-dateRange{
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .ant-checkbox-group{
        display: flex;
        flex-wrap: wrap;
        .xl-checkbox{
            display: flex;
            align-items: center;
            /deep/ span:nth-child(2):not(.ant-checkbox-inner){
                display: flex;
                justify-content: space-between;
                white-space: pre;
            }
        }
    }
</style>
